home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / Timing / UpTime17.lha / UpTime / scripts / OnOff < prev    next >
Encoding:
Text File  |  1994-01-10  |  3.4 KB  |  134 lines

  1. ;
  2. ;   $VER: OnOff 1.1 (09.01.94)
  3. ;
  4. ;   Written 21. September 1993 by J.Matern
  5. ;   This file is part of the 'UpTime'-package © by Jürgen Matern.
  6. ;   The package may be redistributed under limitations discribed
  7. ;   in the file 'UpTime.doc' which should have come with this
  8. ;   distribution. Read this file for more information!
  9. ;
  10. ;   Last changed: 9. January 1994
  11. ;
  12. set lastdate `date`
  13. if exists ENV:UpTime/UpDate
  14.    set lastdate `getenv UpTime/UpDate`
  15. endif
  16. set OnOffFileName S:OnOff.++
  17. if exists ENV:UpTime/OnOffFileName
  18.    set OnOffFileName `getenv UpTime/OnOffFileName`
  19. endif
  20. set resets 0
  21. if exists ENV:UpTime/resets
  22.    set resets `getenv UpTime/resets`
  23. endif
  24. set yesterday yesterday
  25. if exists ENV:UpTime/yesterday
  26.    set yesterday `getenv UpTime/yesterday`
  27. endif
  28. set tomorrow tomorrow
  29. if exists ENV:UpTime/tomorrow
  30.    set tomorrow `getenv UpTime/tomorrow`
  31. endif
  32. set lastday `S:CutArg $lastdate`
  33. set nowdate $LogBoot
  34. set nowday $NowBoot
  35.  
  36. if "$lastday" eq "$nowday"
  37.    set correct 0
  38. else
  39.    date day $yesterday
  40.    set yeday `date`
  41.    date day $tomorrow
  42.    set yeday `S:CutArg $yeday`
  43.    if "$lastday" eq "$yeday"
  44.        set correct 1440
  45.    else
  46.        set correct 10000
  47.    endif
  48.    unset yeday
  49. endif
  50.  
  51. set lasttime `echo "$lastdate" len 8`
  52. set nowtime `echo "$nowdate" len 8`
  53. set lhh `echo $lasttime first 1 len 1`
  54. set lhl `echo $lasttime first 2 len 1`
  55. set lmh `echo $lasttime first 4 len 1`
  56. set lml `echo $lasttime first 5 len 1`
  57. set nhh `echo $nowtime first 1 len 1`
  58. set nhl `echo $nowtime first 2 len 1`
  59. set nmh `echo $nowtime first 4 len 1`
  60. set nml `echo $nowtime first 5 len 1`
  61. set lh `eval $lhh * 10 + $lhl`
  62. set lm `eval $lmh * 10 + $lml`
  63. set nh `eval $nhh * 10 + $nhl`
  64. set nm `eval $nmh * 10 + $nml`
  65. set lm `eval 0 + $lh * 60 + $lm`
  66. set nm `eval 0 + $nh * 60 + $nm + $correct`
  67. set dif `eval $nm - $lm`
  68.  
  69. if val $dif gt 12
  70. ; Change this -^ value, if you changed the default in 'IncreaseUpTime'!
  71. ; Example: You increase your UpTime every 5 minutes and your system needs
  72. ; about 2 minutes to boot after a reset, then set this value to 7 (=5+2)!
  73.    set lastyear `echo $LastBoot len 2`
  74.    set lastyear `echo "$lastyear" first 4 len 2`
  75.    set nowyear `echo $NowBoot len 2`
  76.    set nowyear `echo "$nowyear" first 4 len 2`
  77.  
  78.    if $lastyear not eq $nowyear
  79.       set newyear 1
  80.       if val $resets not eq 0
  81.          if val $resets eq 1
  82.             echo >> $OnOffFileName You had 1 reset!
  83.          else
  84.             echo >> $OnOffFileName You had $resets resets!
  85.          endif
  86.       endif
  87.       echo >> $OnOffFileName Turned system off: $lastdate
  88.       echo > ENVARC:UpTime/resets 0
  89.       echo >> T:OnOff.temp "Turned system on: " $nowdate
  90.    else
  91.       if val $resets not eq 0
  92.          if val $resets eq 1
  93.             echo >> $OnOffFileName You had 1 reset!
  94.          else
  95.             echo >> $OnOffFileName You had $resets resets!
  96.          endif
  97.       endif
  98.       echo >> $OnOffFileName Turned system off: $lastdate
  99.       echo > ENVARC:UpTime/resets 0
  100.       echo >> $OnOffFileName "*NTurned system on: " $nowdate
  101.    endif
  102. else
  103.    set resets `eval $resets + 1`
  104.    echo > ENVARC:UpTime/resets $resets
  105. endif
  106. echo > ENVARC:UpTime/UpDate $nowdate
  107.  
  108. unset lastdate
  109. unset nowdate
  110. unset lastday
  111. unset nowday
  112. unset lastyear
  113. unset nowyear
  114. unset correct
  115. unset lasttime
  116. unset nowtime
  117. unset lh
  118. unset lm
  119. unset nh
  120. unset nm
  121. unset lhh
  122. unset lhl
  123. unset nhh
  124. unset nhl
  125. unset lmh
  126. unset lml
  127. unset nmh
  128. unset nml
  129. unset dif
  130. unset resets
  131. unset yesterday
  132. unset tomorrow
  133. ; don't "unset newyear"; it's needed in file "S:CheckBootDate"
  134.